using System;
using System.Data;
using System.Collections.Generic;

namespace SERP.DAO{
	/********************************BEGIN PeopleDAO****************************************/
	///<summary>
	/// <para>Author: Auto generated class by CSharp Code Generator v2.0</para>
	/// <para>Date:09/03/2013 19:09:04</para>
	/// <para>Class Name: PeopleDAO</para>
	/// <para>Description: Class access to table People in database. Coder should'nt code here.</para>
	///</summary>

	
	public partial class PeopleDAO : DAOBase<PeopleEntity>{


		#region Select functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateSelectOneCommand</para>
		/// <para>Input: PersonId</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectOneCommand(int PersonId){
			string strSQL="SELECT  [PersonId],[PersonCode],[FullName],[OrganizationId],[Gender],[BirthDay],[Address],[Phone],[Email],[PositionId],[StartDate],[Note],[PersonTypeId],[UserId] FROM [People]  WHERE [People].[PersonId]=@PersonId";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@PersonId",PersonId);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: SelectOne</para>
		/// <para>Input: PersonId</para>
		/// <para>Output: PeopleEntity</para>
		///</summary>
		public PeopleEntity SelectOne(int PersonId){
			IDbCommand cmd=this.CreateSelectOneCommand(PersonId);
			return this.Select(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateSelectAllCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllCommand(){
			string strSQL="SELECT  [PersonId],[PersonCode],[FullName],[OrganizationId],[Gender],[BirthDay],[Address],[Phone],[Email],[PositionId],[StartDate],[Note],[PersonTypeId],[UserId] FROM [People] ";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateSelectAllByKeyCommand</para>
		/// <para>Input: ColumnName,ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllByKeyCommand(string ColumnName,object Value){
			string strSQL="SELECT  [PersonId],[PersonCode],[FullName],[OrganizationId],[Gender],[BirthDay],[Address],[Phone],[Email],[PositionId],[StartDate],[Note],[PersonTypeId],[UserId] FROM [People]  WHERE [People].["+ColumnName+"]=@ColumnName";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: SelectAll</para>
		/// <para>Input: </para>
		/// <para>Output: List of PeopleEntity</para>
		///</summary>
		public List<PeopleEntity> SelectAll(){
			IDbCommand cmd=this.CreateSelectAllCommand();
			return this.SelectList(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: SelectAllDS</para>
		/// <para>Input: </para>
		/// <para>Output: DataSet</para>
		///</summary>
		public DataSet SelectAllDS(){
			IDbCommand cmd=this.CreateSelectAllCommand();
			return this.SelectDS(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateSelectAllFilterCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllFilterCommand(string strFilter){
			string strSQL="SELECT  [PersonId],[PersonCode],[FullName],[OrganizationId],[Gender],[BirthDay],[Address],[Phone],[Email],[PositionId],[StartDate],[Note],[PersonTypeId],[UserId] FROM [People]  WHERE "+RemoveInjection(strFilter);
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateSelectAllByKeyFilterCommand</para>
		/// <para>Input: ColumnName,ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllByKeyFilterCommand(string strFilter,string ColumnName,object Value){
			string strSQL="SELECT  [PersonId],[PersonCode],[FullName],[OrganizationId],[Gender],[BirthDay],[Address],[Phone],[Email],[PositionId],[StartDate],[Note],[PersonTypeId],[UserId] FROM [People]  WHERE [People].["+ColumnName+"]=@ColumnName AND "+RemoveInjection(strFilter);
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: SelectAll</para>
		/// <para>Input: </para>
		/// <para>Output: List of PeopleEntity</para>
		///</summary>
		public List<PeopleEntity> SelectAllFilter(string strFilter){
			IDbCommand cmd=this.CreateSelectAllFilterCommand(strFilter);
			return this.SelectList(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: SelectAllDSFilter</para>
		/// <para>Input: </para>
		/// <para>Output: DataSet</para>
		///</summary>
		public DataSet SelectAllDSFilter(string strFilter){
			IDbCommand cmd=this.CreateSelectAllFilterCommand(strFilter);
			return this.SelectDS(cmd);
		}
		#endregion

		#region Insert functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateInsertCommand</para>
		/// <para>Input: PeopleEntity</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateInsertCommand(PeopleEntity o){
			string strSQL="INSERT INTO [People]([PersonCode],[FullName],[OrganizationId],[Gender],[BirthDay],[Address],[Phone],[Email],[PositionId],[StartDate],[Note],[PersonTypeId],[UserId]) VALUES  (@PersonCode,@FullName,@OrganizationId,@Gender,@BirthDay,@Address,@Phone,@Email,@PositionId,@StartDate,@Note,@PersonTypeId,@UserId);SELECT  @@IDENTITY";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullPersonCode)
				this.CreateCommandParameter(cmd,"@PersonCode",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@PersonCode",o.PersonCode);

			if(o.IsNullFullName)
				this.CreateCommandParameter(cmd,"@FullName",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@FullName",o.FullName);

			if(o.IsNullOrganizationId)
				this.CreateCommandParameter(cmd,"@OrganizationId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@OrganizationId",o.OrganizationId);

			if(o.IsNullGender)
				this.CreateCommandParameter(cmd,"@Gender",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Gender",o.Gender);

			if(o.IsNullBirthDay)
				this.CreateCommandParameter(cmd,"@BirthDay",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@BirthDay",o.BirthDay);

			if(o.IsNullAddress)
				this.CreateCommandParameter(cmd,"@Address",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Address",o.Address);

			if(o.IsNullPhone)
				this.CreateCommandParameter(cmd,"@Phone",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Phone",o.Phone);

			if(o.IsNullEmail)
				this.CreateCommandParameter(cmd,"@Email",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Email",o.Email);

			if(o.IsNullPositionId)
				this.CreateCommandParameter(cmd,"@PositionId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@PositionId",o.PositionId);

			if(o.IsNullStartDate)
				this.CreateCommandParameter(cmd,"@StartDate",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@StartDate",o.StartDate);

			if(o.IsNullNote)
				this.CreateCommandParameter(cmd,"@Note",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Note",o.Note);

			if(o.IsNullPersonTypeId)
				this.CreateCommandParameter(cmd,"@PersonTypeId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@PersonTypeId",o.PersonTypeId);

			if(o.IsNullUserId)
				this.CreateCommandParameter(cmd,"@UserId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@UserId",o.UserId);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: Save</para>
		/// <para>Input: PeopleEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Save(PeopleEntity o){
			bool result=false;
			IDbCommand cmd=this.CreateInsertCommand(o);
			object id=this.ExecuteScalar(cmd,ref result);
			cmd.Dispose();
			try{
				o.PersonId=int.Parse(Convert.ToString(id));
			}
			catch{}
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: SaveList</para>
		/// <para>Input: List of PeopleEntity</para>
		/// <para>Output: </para>
		///</summary>
		public void SaveList(List<PeopleEntity>list){
			foreach(PeopleEntity o in list){
				try{
					this.Save(o);
				}
				catch{
				}
			}
		}
		#endregion

		#region Update functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateUpdateCommand</para>
		/// <para>Input: PeopleEntity</para>
		/// <para>Output: </para>
		///</summary>
		protected IDbCommand CreateUpdateCommand(PeopleEntity o){
			string strSQL="UPDATE  [People] SET [People].[PersonCode]=@PersonCode,[People].[FullName]=@FullName,[People].[OrganizationId]=@OrganizationId,[People].[Gender]=@Gender,[People].[BirthDay]=@BirthDay,[People].[Address]=@Address,[People].[Phone]=@Phone,[People].[Email]=@Email,[People].[PositionId]=@PositionId,[People].[StartDate]=@StartDate,[People].[Note]=@Note,[People].[PersonTypeId]=@PersonTypeId,[People].[UserId]=@UserId WHERE [People].[PersonId]=@PersonId";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullPersonCode)
				this.CreateCommandParameter(cmd,"@PersonCode",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@PersonCode",o.PersonCode);

			if(o.IsNullFullName)
				this.CreateCommandParameter(cmd,"@FullName",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@FullName",o.FullName);

			if(o.IsNullOrganizationId)
				this.CreateCommandParameter(cmd,"@OrganizationId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@OrganizationId",o.OrganizationId);

			if(o.IsNullGender)
				this.CreateCommandParameter(cmd,"@Gender",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Gender",o.Gender);

			if(o.IsNullBirthDay)
				this.CreateCommandParameter(cmd,"@BirthDay",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@BirthDay",o.BirthDay);

			if(o.IsNullAddress)
				this.CreateCommandParameter(cmd,"@Address",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Address",o.Address);

			if(o.IsNullPhone)
				this.CreateCommandParameter(cmd,"@Phone",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Phone",o.Phone);

			if(o.IsNullEmail)
				this.CreateCommandParameter(cmd,"@Email",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Email",o.Email);

			if(o.IsNullPositionId)
				this.CreateCommandParameter(cmd,"@PositionId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@PositionId",o.PositionId);

			if(o.IsNullStartDate)
				this.CreateCommandParameter(cmd,"@StartDate",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@StartDate",o.StartDate);

			if(o.IsNullNote)
				this.CreateCommandParameter(cmd,"@Note",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Note",o.Note);

			if(o.IsNullPersonTypeId)
				this.CreateCommandParameter(cmd,"@PersonTypeId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@PersonTypeId",o.PersonTypeId);

			if(o.IsNullUserId)
				this.CreateCommandParameter(cmd,"@UserId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@UserId",o.UserId);

			if(o.IsNullPersonId)
				this.CreateCommandParameter(cmd,"@PersonId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@PersonId",o.PersonId);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateUpdateFieldCommand</para>
		/// <para>Input: ColumnName,ColumnValue,PersonId</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateUpdateFieldCommand(string ColumnName,object Value,int PersonId){
			string strSQL="UPDATE  [People] SET [People].["+ColumnName+"]=@ColumnName WHERE [People].[PersonId]=@PersonId";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@PersonId",PersonId);



			this.CreateCommandParameter(cmd,"@ColumnName",Value);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: Update</para>
		/// <para>Input: PeopleEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Update(PeopleEntity o){
			IDbCommand cmd=this.CreateUpdateCommand(o);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateList</para>
		/// <para>Input: List of PeopleEntity</para>
		/// <para>Output: </para>
		///</summary>
		public void UpdateList(List<PeopleEntity>list){
			foreach(PeopleEntity o in list){
				try{
					this.Update(o);
				}
				catch{
				}
			}
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdatePersonCode</para>
		/// <para>Input: NewPersonCode,PersonId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdatePersonCode(string NewPersonCode,int PersonId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("PersonCode",NewPersonCode,PersonId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateFullName</para>
		/// <para>Input: NewFullName,PersonId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateFullName(string NewFullName,int PersonId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("FullName",NewFullName,PersonId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateOrganizationId</para>
		/// <para>Input: NewOrganizationId,PersonId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateOrganizationId(int NewOrganizationId,int PersonId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("OrganizationId",NewOrganizationId,PersonId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateGender</para>
		/// <para>Input: NewGender,PersonId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateGender(Byte NewGender,int PersonId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("Gender",NewGender,PersonId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateBirthDay</para>
		/// <para>Input: NewBirthDay,PersonId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateBirthDay(DateTime NewBirthDay,int PersonId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("BirthDay",NewBirthDay,PersonId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateAddress</para>
		/// <para>Input: NewAddress,PersonId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateAddress(string NewAddress,int PersonId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("Address",NewAddress,PersonId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdatePhone</para>
		/// <para>Input: NewPhone,PersonId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdatePhone(string NewPhone,int PersonId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("Phone",NewPhone,PersonId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateEmail</para>
		/// <para>Input: NewEmail,PersonId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateEmail(string NewEmail,int PersonId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("Email",NewEmail,PersonId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdatePositionId</para>
		/// <para>Input: NewPositionId,PersonId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdatePositionId(int NewPositionId,int PersonId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("PositionId",NewPositionId,PersonId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateStartDate</para>
		/// <para>Input: NewStartDate,PersonId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateStartDate(DateTime NewStartDate,int PersonId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("StartDate",NewStartDate,PersonId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateNote</para>
		/// <para>Input: NewNote,PersonId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateNote(string NewNote,int PersonId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("Note",NewNote,PersonId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdatePersonTypeId</para>
		/// <para>Input: NewPersonTypeId,PersonId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdatePersonTypeId(int NewPersonTypeId,int PersonId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("PersonTypeId",NewPersonTypeId,PersonId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: UpdateUserId</para>
		/// <para>Input: NewUserId,PersonId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateUserId(int NewUserId,int PersonId){
			IDbCommand cmd=this.CreateUpdateFieldCommand("UserId",NewUserId,PersonId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		#endregion

		#region Delete functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: DeleteAllCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteAllCommand(){
			string strSQL="DELETE   FROM [People]  ";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: DeleteCommand</para>
		/// <para>Input: PeopleEntity</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteCommand(PeopleEntity o){
			string strSQL="DELETE   FROM [People]   WHERE [People].[PersonId]=@PersonId";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullPersonId)
				this.CreateCommandParameter(cmd,"@PersonId",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@PersonId",o.PersonId);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: DeleteAll</para>
		/// <para>Input: </para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool DeleteAll(){
			IDbCommand cmd=this.CreateDeleteAllCommand();
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateDeleteByPrimaryKeyCommand</para>
		/// <para>Input: PersonId</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteByPrimaryKeyCommand(int PersonId){
			string strSQL="DELETE   FROM [People]   WHERE [People].[PersonId]=@PersonId";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@PersonId",PersonId);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: CreateDeleteByKeyCommand</para>
		/// <para>Input: ColumnName , ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteByKeyCommand(string ColumnName,object Value){
			string strSQL="DELETE   FROM [People]   WHERE [People].["+ColumnName+"]=@ColumnName";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: Delete</para>
		/// <para>Input: PeopleEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Delete(PeopleEntity o){
			IDbCommand cmd=this.CreateDeleteCommand(o);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: DeleteByID</para>
		/// <para>Input: PersonId</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool DeleteByID(int PersonId){
			IDbCommand cmd=this.CreateDeleteByPrimaryKeyCommand(PersonId);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		#endregion

		#region Select join to OrganizationsPersonTypesWorkPositions functions
		#endregion

		#region Select join to Organizations functions
		#endregion

		#region Select join to PersonTypes functions
		#endregion

		#region Select join to WorkPositions functions
		#endregion

		#region Select,delete by PersonId functions
		#endregion

		#region Select,delete by OrganizationId functions
		#endregion

		#region Select,delete by PositionId functions
		#endregion

		#region Select,delete by PersonTypeId functions
		#endregion

		#region MapObject functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:09/03/2013 19:09:04</para>
		/// <para>Name: MapObject</para>
		/// <para>Input: IDataReader</para>
		/// <para>Output: PeopleEntity</para>
		///</summary>
		protected override PeopleEntity MapObject(IDataReader r){
			PeopleEntity entity = new PeopleEntity();
			try{
				if(r.FieldCount>0){
					try
					{
						int ordinal = r.GetOrdinal("PersonId");
						if (!r.IsDBNull(ordinal)) entity.PersonId = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("PersonCode");
						if (!r.IsDBNull(ordinal)) entity.PersonCode = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("FullName");
						if (!r.IsDBNull(ordinal)) entity.FullName = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("OrganizationId");
						if (!r.IsDBNull(ordinal)) entity.OrganizationId = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("Gender");
						if (!r.IsDBNull(ordinal)) entity.Gender = ((Byte)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("BirthDay");
						if (!r.IsDBNull(ordinal)) entity.BirthDay = ((DateTime)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("Address");
						if (!r.IsDBNull(ordinal)) entity.Address = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("Phone");
						if (!r.IsDBNull(ordinal)) entity.Phone = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("Email");
						if (!r.IsDBNull(ordinal)) entity.Email = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("PositionId");
						if (!r.IsDBNull(ordinal)) entity.PositionId = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("StartDate");
						if (!r.IsDBNull(ordinal)) entity.StartDate = ((DateTime)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("Note");
						if (!r.IsDBNull(ordinal)) entity.Note = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("PersonTypeId");
						if (!r.IsDBNull(ordinal)) entity.PersonTypeId = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("UserId");
						if (!r.IsDBNull(ordinal)) entity.UserId = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					return entity;
				}
			}catch{}
			return null;
		}
		#endregion
	}
	/*****************************************************************************************************/
	/**********************************END PeopleDAOBase*****************************************/
	/*****************************************************************************************************/
}

